package com.ucarbon.ucarbon.service.impl;

import com.ucarbon.ucarbon.entity.CountryLandstype;
import com.ucarbon.ucarbon.mapper.CountryLandstypeMapper;
import com.ucarbon.ucarbon.service.ICountryLandstypeService;
import com.ucarbon.ucarbon.utils.EchartsOptionsGnerator;
import com.ucarbon.ucarbon.utils.RespBean;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 土地利用类型与城年份对应信息 服务实现类
 * </p>
 *
 * @author XuGaoran
 * @since 2024-01-12
 */
@Service
public class CountryLandstypeServiceImpl extends ServiceImpl<CountryLandstypeMapper, CountryLandstype>
        implements ICountryLandstypeService {

    @Autowired
    private CountryLandstypeMapper countryLandstypeMapper;

    @Override
    public RespBean queryCountryYearLandty(String country, Integer year) {
        try {
            return RespBean.success("生成Pie选项成功", EchartsOptionsGnerator.generatePieOptions(country, year,
                    countryLandstypeMapper.selectPrecentByCountryYear(country, year)));
        } catch (Exception e) {
            return RespBean.error("生成数据失败", e);
        }
    }

}
